package com.team.six.bluecatshop.service;


import com.team.six.bluecatshop.domain.TestYingsheProduct;
import com.team.six.bluecatshop.mapper.TestYingsheProductMapper;
import com.team.six.bluecatshop.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class TestYingsheProductServiceImpl implements TestYingsheProductService {
    @Autowired
    private TestYingsheProductMapper testYingsheProductMapper;
    @Autowired
    private ProductMapper productMapper;

    @Override
    @Transactional
    public void add(TestYingsheProduct testYingsheProduct) {
        testYingsheProductMapper.insert(testYingsheProduct);
    }

    @Override
    @Transactional
    public void remove(int id) {
        testYingsheProductMapper.deleteByPrimaryKey(id);
    }

    @Override
    public TestYingsheProduct findById(int id) {
        TestYingsheProduct testYingsheProduct=testYingsheProductMapper.selectByPrimaryKey(id);
        return testYingsheProduct;
    }

    @Override
    public List<TestYingsheProduct> findAll() {
        List<TestYingsheProduct> testYingsheProductList = testYingsheProductMapper.findAll();
        return testYingsheProductList;
    }

    @Override
    public TestYingsheProduct findTestYingsheProductByProductId(String id) {
        TestYingsheProduct testYingsheProduct = testYingsheProductMapper.findByProductId(id);
        return testYingsheProduct;
    }


    @Override
    @Transactional
    public void updateByPrimaryKey(TestYingsheProduct testYingsheProduct) {
        testYingsheProductMapper.updateByPrimaryKeySelective(testYingsheProduct);
    }


}
